function _finally(this:any,callback:Function) {
  let P = this.constructor;
  return this.then(
    (value:any) => P.resolve(callback()).then(() => value),
    (reason:Error) => P.resolve(callback()).then(() => { throw reason })
  );
};

if(!Promise.prototype.finally){
  Promise.prototype.finally = <any>_finally
}

export default _finally
